<template>
    <div class="newsinfo-container">
        <h2 class="title">{{newsinfo.title}}</h2>
        <p class="subtitle">
            <span>发表时间：{{newsinfo.add_time | dateFormat}}</span>
            <span>点击：{{newsinfo.click}}次</span>
        </p>
        <hr>
        <div class="content" v-html="newsinfo.content"></div>
        <comment-box :id="this.id"></comment-box>
    </div>
</template>

<script>
import comment from '../subcomponents/comment.vue'
import {Toast} from 'mint-ui'
export default {
    data() {
        return {
            id: this.$route.params.id,
            newsinfo: {}
        }
    },
    methods: {
        getNewsInfo(){
            this.$http.get('output/news/info.php?id='+this.id).then(function(result){
                //console.log(result.body.message);
                if (result.body.status===0) {
                    this.newsinfo=result.body.message[0]
                }else{
                    Toast("详情加载失败。。。")
                }
            })
        }
    },
    created() {
        this.getNewsInfo()
    },
    components: {
        "comment-box": comment
    }
}
</script>

<style lang="scss" scoped>
.newsinfo-container{
    padding: 0 5px;
    .title{
        font-size: 20px;
        text-align: center;
        margin: 15px 0;
        color: #6ea4ec;
    }
    .subtitle{
        display: flex;
        justify-content: space-between;
    }
}
</style>
